package com.malamute.system.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.malamute.core.entity.BaseEntity;

/**
 * @Title:User.java
 * @Package com.restaurant.models
 * @Description 员工
 * @author AceGuan gjybst@163.com
 * @date 2012-1-4 下午01:53:11
 * @version v1.0
 */
@Entity
@Table(name = "T_SYS_USER")
public class User extends BaseEntity {

	/**
	 * serialVersionUID:TODO（用一句话描述这个变量表示什么）
	 */
	private static final long serialVersionUID = 1L;

	private String name;// 姓名

	private String username;// 登录名

	private String password;// 密码

	private int mobilePhone;// 移动电话

	private String email;// 邮件地址

	private boolean isAdmin = false;// 是否管理员

	private String idCard;// 证件号

	private String address;// 地址
	
	private int age;//年龄
	
	@Enumerated(value = EnumType.ORDINAL)
	private Gender gender = Gender.MAN;// 性别


	// 有中间表关联的多对一
	@ManyToOne(targetEntity = Role.class, fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
	@JoinTable(name = "T_SYS_USER_ROLE_MTO", joinColumns = @JoinColumn(name = "u_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "r_id", referencedColumnName = "id"))
	private Role role;

	// // 无表关联多对一
	// @ManyToOne(targetEntity = Address.class)
	// private Address address;

	// 无中间表@OneToOne
	// @OneToOne
	// @JoinColumn(name = "idCard_Id")
	// private IDCard iDCard;
	// 有中间表 @OneToOne
	// @OneToOne
	// @JoinTable(name = "t_sys_user_passport", joinColumns = @JoinColumn(name =
	// "user_id"), inverseJoinColumns = @JoinColumn(name = "passport_id"))
	// private Passport passport;


	/**
	 * 获取name
	 * 
	 * @return name
	 */

	public String getName() {
		return name;
	}

	/**
	 * 设置name
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获取username
	 * 
	 * @return username
	 */

	public String getUsername() {
		return username;
	}

	/**
	 * 设置username
	 * 
	 * @param username
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * 获取password
	 * 
	 * @return password
	 */

	public String getPassword() {
		return password;
	}

	/**
	 * 设置password
	 * 
	 * @param password
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * 获取mobilePhone
	 * 
	 * @return mobilePhone
	 */

	public int getMobilePhone() {
		return mobilePhone;
	}

	/**
	 * 设置mobilePhone
	 * 
	 * @param mobilePhone
	 */
	public void setMobilePhone(int mobilePhone) {
		this.mobilePhone = mobilePhone;
	}

	/**
	 * 获取email
	 * 
	 * @return email
	 */

	public String getEmail() {
		return email;
	}

	/**
	 * 设置email
	 * 
	 * @param email
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * 获取gender
	 * 
	 * @return gender
	 */

	public Gender getGender() {
		return gender;
	}

	/**
	 * 设置gender
	 * 
	 * @param gender
	 */
	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public boolean isAdmin() {
		return isAdmin;
	}

	public void setAdmin(boolean isAdmin) {
		this.isAdmin = isAdmin;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

}
